package playn.platformer;

import java.util.HashMap;

import com.allen_sauer.gwt.log.client.Log;

import playn.core.Image;
import playn.core.Surface;
import playn.core.SurfaceLayer;

import tiled.simple.core.Renderer;

public class StaticRenderer implements Renderer{

	private HashMap<String,Image> imagesCache = new HashMap<String, Image>();

	public SurfaceLayer layer;

	public StaticRenderer(HashMap<String,Image> imagesCache){
		this.imagesCache=imagesCache;
	}
	
	public void putImage(String source, int sx, int sy, int sw, int sh, int dx,int dy, int dw, int dh) {
			Image image=null;
			
			if(!imagesCache.containsKey(source)){
				Log.error("you have to load "+source+" image from loader using imagesCache");
			} else {
				image=imagesCache.get(source);
			}

			Surface surface = layer.surface();
			surface.drawImage(image, dx, dy, dw, dh, sx, sy, sw, sh);

	}

}
